﻿<%@ WebHandler Language="C#" Class="GalleryHandler" %>

using System;
using System.Web;
using SeDuce.BLL;
using SeDuce.Model;
using System.Collections.Generic;
using System.Linq;

public class GalleryHandler : IHttpHandler {

    Lazy_Yu<GalleryBLL> lazyGalleryBLL = new Lazy_Yu<GalleryBLL>(() => new GalleryBLL());
    public GalleryBLL LazyGalleryBLL
    {
        get { return this.lazyGalleryBLL.Value; }
    }
    
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        List<GalleryPic> pics = LazyGalleryBLL.GetPics().ToList<GalleryPic>().OrderByDescending(p => p.ID).Take<GalleryPic>(4).ToList<GalleryPic>().Shuffle<GalleryPic>();
        context.Response.Write(pics.ToJSON());
        context.Response.End();
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}